import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import {VantResolver} from '@vant/auto-import-resolver';

// https://vitejs.dev/config/
export default defineConfig({
    server: {
        port: 4445,
        open: true,
        host: '0.0.0.0',
        proxy: {
            // 匹配.env.development中配置的VITE_API_BASE_URL前缀
            '/dev-api': {
                target: 'http://localhost:8081', // 后端服务实际地址
                changeOrigin: true, // 开启跨域
            }
        }

    },
    plugins: [
        vue(),
        Components({
            resolvers: [VantResolver()],
        }),
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    }
})
